const express = require("express");
const mongoose = require("mongoose");
const bodyParser = require("body-parser");
const passport = require('passport');
const app = express();

// 使用body-parser的中间件
// app.use(bodyParser.urlencode({extended: false}));
app.use(bodyParser.json());

// passport初始化
app.use(passport.initialize());
require ('./config/passport')(passport);

// 引入user
const users = require('./routes/api/users');
const profiles = require('./routes/api/profiles');

// 使用routes
app.use('/api/users', users);
app.use('/api/profiles', profiles);

const port = process.env.PORT || 4000;

app.listen(port, () => {
    console.log(`server is running on port ${port}`);
});